package com.example.soapserver.service;

import com.example.soapserver.model.pending.PendingWork;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicLong;

@Service
public class PendingService {
    private final List<PendingWork> pendingWorks = new ArrayList<>();
    private final AtomicLong counter = new AtomicLong();

    @PostConstruct
    public void init() {
        // 初始化一些测试数据
        PendingWork pendingWork = new PendingWork();
        pendingWork.setId(counter.incrementAndGet());
        pendingWork.setAppSendUID("123456");
        pendingWork.setStatus("Pending");
        pendingWork.setTaskName("Task 1");
        pendingWork.setTaskType("Type 1");
        pendingWork.setUrl("http://example.com/task1");
        pendingWork.setTaskDesc("This is task 1");

        pendingWorks.add(pendingWork);


        PendingWork pendingWork1 = new PendingWork();;
        pendingWork1.setId(counter.incrementAndGet());
        pendingWork1.setAppSendUID("123456");
        pendingWork1.setStatus("Pending1");
        pendingWork1.setTaskName("Task 2");
        pendingWork1.setTaskType("Type 2");
        pendingWork1.setUrl("http://example.com/task2");
        pendingWork1.setTaskDesc("This is task 2");
        pendingWorks.add(pendingWork1);

    }


    public List<PendingWork> getAll() {
        return new ArrayList<>(pendingWorks);
    }


}